package com.example.lanqiaodemo1.java11;

public class sum {
    public static void main(String[] args) {
        Dog dog = new Dog();
        Cat cat = new Cat();
        System.out.println(dog.getMoney() * 2 + cat.getMoney());
    }
}
class Cat extends Animal {
    @Override
    public double getMoney() {
        this.setPrice(2.5);
        this.setCount(0.5);
        return getCount() * getPrice();
    }
}
class Dog extends Animal {

    @Override
    public double getMoney() {
        this.setPrice(1.5);
        this.setCount(2);
        return getCount() * getPrice();
    }
}
abstract class Animal {
    private double price;
    private double count;
    public abstract double getMoney();
    public Animal(double price, double count) {
        this.price = price;
        this.count = count;
    }

    public Animal() {
    }

    public double getPrice() { return price; }

    public void setPrice(double price) {
        this.price = price;
    }

    public double getCount() {
        return count;
    }

    public void setCount(double count) {
        this.count = count;
    }
}
